package shaw.wifi.network;

import shaw.wifi.NetworkSettingsTaskManager;
import shaw.wifi.gui.SecureConnectGui;
import android.os.AsyncTask;
import android.util.Log;

public abstract class AsyncNetworkTask extends AsyncTask<ConnectionInformation, String, Integer>  {
	@Override
	protected void onPostExecute(Integer result) {
		Log.e("TASK", "POST-EXECUTE");
		NetworkSettingsTaskManager.get().getNSTR().taskComplete();
	}
	
	@Override
	protected void onProgressUpdate(String... messages) {
		if(this.isCancelled() == true) {
			return;
		}
		for(int i = 0; i<messages.length; i++) {
			SecureConnectGui.get().addLineToOutput(messages[i]);
		}
	}
	
	public void outputMessage(String msg) {
		this.publishProgress(msg);
	}
	
	//whether or not the async task is interruptable
	//this does not inforce this anywhere, but the app should check before canceling any
	//NetworkSettingsTasks via getInteruptable()
	protected boolean interruptable = true;
	public boolean getInterruptable() {
		return interruptable;
	}
}
